<template>
  <el-container class="layout-container">
    <el-header class="header">
      <div class="logo">后台管理系统</div>
      <div class="header-right">
        <el-dropdown>
          <span class="el-dropdown-link">
            管理员
            <el-icon class="el-icon--right"><arrow-down /></el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </el-header>
    
    <el-container>
      <el-aside width="280px">
        <el-menu
          :default-active="activeMenu"
          class="el-menu-vertical"
          :router="true"
          @select="handleSelect"
        >
          <el-menu-item index="/welcome">
            <el-icon><home-filled /></el-icon>
            <span>欢迎页面</span>
          </el-menu-item>

          <el-sub-menu index="/resume">
            <template #title>
              <el-icon><document /></el-icon>
              <span>简历相关</span>
            </template>
            <el-sub-menu index="/resume/calculation">
              <template #title>
                <el-icon><calculator /></el-icon>
                <span>简历计算</span>
              </template>
              <el-menu-item index="/resume/calculation/quality-score">计算简历质量评分</el-menu-item>
              <el-menu-item index="/resume/calculation/batch-quality-score">批量计算质量分</el-menu-item>
            </el-sub-menu>
            <el-sub-menu index="/resume/query">
              <template #title>
                <el-icon><search /></el-icon>
                <span>简历查询</span>
              </template>
              <el-menu-item index="/resume/query/preview-resume">简历预览</el-menu-item>
            </el-sub-menu>
          </el-sub-menu>

          <el-sub-menu index="/menu1">
            <template #title>
              <el-icon><folder /></el-icon>
              <span>目录1</span>
            </template>
            <el-menu-item index="/menu1/test1">测试页面1</el-menu-item>
            <el-menu-item index="/menu1/test2">测试页面2</el-menu-item>
          </el-sub-menu>

          <el-sub-menu index="/menu2">
            <template #title>
              <el-icon><folder /></el-icon>
              <span>目录2</span>
            </template>
            <el-menu-item index="/menu2/test3">测试页面3</el-menu-item>
            <el-sub-menu index="/menu2/menu3">
              <template #title>
                <el-icon><folder /></el-icon>
                <span>目录3</span>
              </template>
              <el-menu-item index="/menu2/menu3/test4">测试页面4</el-menu-item>
              <el-menu-item index="/menu2/menu3/test5">测试页面5</el-menu-item>
            </el-sub-menu>
          </el-sub-menu>

          <el-menu-item index="/help">
            <el-icon><question-filled /></el-icon>
            <span>帮助</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'
import {
  HomeFilled,
  Folder,
  QuestionFilled,
  ArrowDown
} from '@element-plus/icons-vue'

const route = useRoute()
const activeMenu = computed(() => route.path)

const handleSelect = (key: string) => {
  console.log(key)
}
</script>

<style scoped>
.layout-container {
  height: 100vh;
}

.header {
  background-color: #409EFF;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.logo {
  font-size: 20px;
  font-weight: bold;
}

.header-right {
  display: flex;
  align-items: center;
}

.el-dropdown-link {
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.el-menu-vertical {
  height: 100%;
  border-right: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.el-menu-vertical::-webkit-scrollbar {
  width: 6px;
}

.el-menu-vertical::-webkit-scrollbar-thumb {
  background: #c0c4cc;
  border-radius: 3px;
}

.el-menu-vertical::-webkit-scrollbar-track {
  background: #f5f7fa;
}

:deep(.el-sub-menu) {
  .el-sub-menu__title {
    background-color: #f5f7fa !important;
    border-left: 3px solid transparent;
    font-weight: 500;
    color: #606266;
  }

  .el-menu-item {
    padding-left: 40px !important;
  }

  .el-sub-menu .el-menu-item {
    padding-left: 60px !important;
  }
}

:deep(.el-menu-item) {
  margin: 4px 0;
  border-radius: 4px;
  border-left: 3px solid transparent;
  transition: all 0.3s;
  color: #303133;
}

:deep(.el-menu-item:hover) {
  background-color: #ecf5ff !important;
  border-left-color: #409EFF;
}

:deep(.el-menu-item.is-active) {
  background-color: #ecf5ff !important;
  border-left-color: #409EFF;
  color: #409EFF;
}

.el-main {
  background-color: #f0f2f5;
  padding: 20px;
}
</style>
